<%@ page import="util.DBUtil" %><%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2023/10/27
  Time: 10:25
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    request.setCharacterEncoding("utf-8");//设置字符集
    //1.获得录入表单传递的数据
    String typeId       =request.getParameter("type_id");
    String productName  =request.getParameter("product_name");
    String intro        =request.getParameter("intro");
    String price        =request.getParameter("price");
    String salePrice    =request.getParameter("sale_price");
    String isTop        =request.getParameter("is_top");
    String idx          =request.getParameter("idx");
    String status       =request.getParameter("status");

    //2.设置要执行的sql语句
    String sql ="insert into tb_product(type_id,"
            +"product_name,intro,price,sale_price,is_top,idx,status)"
            +"values('"+typeId+"', '"+productName+"','"+intro+"','"+price
            +"','" +salePrice+"','"+isTop+"','"+idx+"','"+status+"')";
    //3.执行
    DBUtil dbUtil =new DBUtil();
    int n=dbUtil.update(sql);
    if (n>0)
        response.sendRedirect("product.jsp");
    else
        out.print("保存失败!");

%>
